package com.bml.architect.rabbitmq.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class RabbitUtils {

    private static ConnectionFactory connectionFactory = new ConnectionFactory();

    static {
        connectionFactory.setHost("192.168.146.130");
        connectionFactory.setPort(5672);//默认的端口号
        connectionFactory.setUsername("baiml");
        connectionFactory.setPassword("123456");
        connectionFactory.setVirtualHost("bmlVm");
    }


    public static Connection getConnection(){

        try {
            return connectionFactory.newConnection();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (TimeoutException e) {
            e.printStackTrace();
        }
        return null;
    }
}
